//
//  MessageListService.m
//  homeland
//
//  Created by caesar on 14-3-7.
//  Copyright (c) 2014年 xzysun. All rights reserved.
//

#import "MessageListService.h"
#import "UserInfoService.h"

@implementation MessageListService
//我的消息列表
-(void)queryMyMessageList:(void (^)(NSArray *data))success Failure:(void (^)(NSString *msg))failure{
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    if ([UserInfoService getUserInfoService].currentLoginUserName) {
        [params setValue:[UserInfoService getUserInfoService].currentLoginUserName forKey:@"userName"];
    } else {
        [params setValue:getDeviceIdentifier() forKey:@"imeiCode"];//要加入的唯一标示
    }
    _currentEngine = [[MKNetworkEngine alloc] initWithHostName:PERSONAL_ALL_MESSAGE_LIST_URL customHeaderFields:nil];
    MKNetworkOperation *op = [_currentEngine operationWithPath:nil params:params httpMethod:@"POST"];
    [op addCompletionHandler:^(MKNetworkOperation *operation) {
        NSArray *json = [operation responseJSON];
        //转换对象,添加到列表中
        success(json);
    }errorHandler:^(MKNetworkOperation *errorOp, NSError* err) {
        NSLog(@"MKNetwork request error : %@", [err localizedDescription]);
        failure(@"请求失败.");
        
    }];
    [_currentEngine enqueueOperation:op];

    }
@end
